import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import http from 'axios'
import 'default-passive-events'
import * as ElIconModules from '@element-plus/icons-vue'
import hljs from 'highlight.js'
import 'highlight.js/styles/atom-one-light.css';
import { Setting,Tickets } from "@element-plus/icons-vue"; //看自己需求取
// 全局方法、组件、变量的定义和挂载 
//通过provide将组件或者方法、变量挂载在全局
//通过inject获取全局方法并调用
const notice = (that) => {
  ElMessageBox.confirm(
    "请尽早完善个人信息",
    "Warning",
    {
      confirmButtonText: "前去",
      cancelButtonText: "跳过",
      type: "warning",
      center: true,
    }
  )
    .then(() => {
      // ElMessage({
      //   type: "success",
      //   message: "Delete completed",
      // });
      that.$router.push({
        path: "/user/center/information",
      });
    })
    .catch(() => {
      ElMessage({
        type: "info",
        message: "暂时跳过",
      });
    });
}


/*
在vue2中会习惯性的把axios挂载到全局，以方便在各个组件或页面中使用this.$http请求接口。
但是在vue3中取消了Vue.prototype，在全局挂载方法和属性时，需要使用官方提供的globalPropertiesAPI。
*/
const app = createApp(App)
app.config.globalProperties.$http = http
//还需要的是配置好defalt相关实例值
app.provide('notice',notice)

Object.keys(ElIconModules).forEach(function (key) {
  app.component(ElIconModules[key].name, ElIconModules[key])
})
app.directive('highlight', function (el) {
  const blocks = el.querySelectorAll('pre code')
  blocks.forEach(block => {
    hljs.highlightBlock(block)
  })
})
app.use(store).use(router);
app.mount('#app')
// http.defaults.baseURL="http://10.60.192.23:8080/"
// http.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'
//createApp(App).use(store).use(router).mount('#app')
